package com.czh.springboot04.service.serviceimpl;

import com.czh.springboot04.entity.ArticleType;
import com.czh.springboot04.mapper.ArticleTypeMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;


@Service
public class ArticleTypeServiceImpl implements com.czh.springboot04.service.ArticleTypeService {
    @Autowired
    private ArticleTypeMapper articleTypeMapper;
    @Override
    public int addArticleType(ArticleType articleType) {
        return articleTypeMapper.insertArticleType(articleType);
    }

    @Override
    public int updateArticleType(ArticleType articleType) {
        return articleTypeMapper.updateArticleType(articleType);
    }

    @Override
    public int deleteArticleType(int id) {
        return articleTypeMapper.deleteArticleType(id);
    }

    @Override
    public int dels(int[] ids) {
        return articleTypeMapper.deleteTypes(ids);
    }

    @Override
    public PageInfo<ArticleType> selectAll(int pageNum,int pageSize,ArticleType articleType) {
        PageHelper.startPage(pageNum, pageSize);
        List<ArticleType> articleTypes = articleTypeMapper.selectAll(articleType);

        return new PageInfo<>(articleTypes);
    }

    @Override
    public List<ArticleType> selectAll() {
        return articleTypeMapper.selectAll(null);
    }

    @Override
    public ArticleType findById(int id){
        return articleTypeMapper.findById(id);
    }
}
